package cn.stylefeng.guns.modular.rest;


import cn.stylefeng.guns.modular.ht.entity.BackRegister;
import cn.stylefeng.guns.modular.ht.model.params.BackRegisterParam;
import cn.stylefeng.guns.modular.ht.model.params.ReportParam;
import cn.stylefeng.guns.modular.ht.service.BackRegisterService;
import cn.stylefeng.guns.modular.ht.service.ReportService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.SuccessResponseData;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


/**
 * 绑定控制器
 *
 * @author
 * @Date 2019-11-18 13:24:11
 */
@RestController
@RequestMapping("/gunsApi/back-register")
public class ApiNeedTokenBackRegisterController extends BaseController {
    @Autowired
    private BackRegisterService backRegisterService;

    /**
     * 绑定
     */
    @RequestMapping(value = "")
    public Object index(BackRegisterParam backRegisterParam) {
        Map map = new HashMap();
        SuccessResponseData SUCCESS_TIP = new SuccessResponseData();

        BackRegister backRegister = backRegisterService.getOne(new QueryWrapper<BackRegister>().eq("account", backRegisterParam.getAccount()));
        map.put("backRegister", backRegister);
        SUCCESS_TIP.setData(map);
        return SUCCESS_TIP;
    }

    /**
     * 绑定
     */
    @RequestMapping(value = "updateItem")
    public Object updateItem(BackRegisterParam backRegisterParam) {
        Map map = new HashMap();
        SuccessResponseData SUCCESS_TIP = new SuccessResponseData();
        backRegisterService.remove(new QueryWrapper<BackRegister>().eq("account", backRegisterParam.getAccount()));
        backRegisterService.add(backRegisterParam);

        SUCCESS_TIP.setData(map);
        return SUCCESS_TIP;
    }

}


